function check400Customer() {
	var name=$("#name").val();
	var area=$("#area").val();
	if(name!=""&&name!=null&&area!=""&&area!=null)
		$("#add400Customer").css({"display":"block"});
	else
		$("#add400Customer").css({"display":"none"});
}
//添加400客户请求
function addNotRegisterCustomer() {
	controllerWaiting(true);
	$(".bg").fadeIn(100);
	var name=$("#name").val();
	
	var phone=$("#phone").val();
	var email=$("#email").val();
	//校验手机号和邮箱
	var re = /^1\d{10}$/;
	var re2 = /^0\d{2,3}-?\d{7,8}$/;	
	if (!re.test(phone) && !re2.test(phone)) {
        alert("请输入正确的手机号码");
        controllerWaiting(false);
        return;
    } 
	
	var re3 = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
	if (!re3.test(email)) {
        alert("请输入正确邮箱地址");
        controllerWaiting(false);
        return;
    } 
	var area=$("#area").val();
	var product=$("#product").val();
	$.ajax({
		type:"post",
		dataType:"text",
		data:{"name":name,"phone":phone,"email":email,"regionalId":area,"productLabel":product},
		url:getContextPath()+"/util/allotNotRegisterCustomer",
		success:function(msg) {
			controllerWaiting(false);
			$(".bg").fadeOut(100);
			if(msg==1){
				alert("添加成功!");
				window.location=getContextPath()+"/util/show400Customer";
			} else {
				alert(msg);
			}
		},
		error:function(request) {
			window.location=getContextPath()+"/util/show400Customer";
		}
	});
}

//400客户转到报备
function addReport(hwnd) {
	var tr=$(hwnd).parent().parent();
	var name=tr.find(".name").text();
	var phone=tr.find(".phone").text();
	var email=tr.find(".email").text();
	var cusId=tr.find(".cusId a").text();
	$.ajax({
		type:"post",
		dataType:"text",
		data:{"cusId":cusId,"name":name,"phone":phone,"email":email},
		url:getContextPath()+"/page/goAddReportedCustomer",
		success:function(msg) {
			window.location=getContextPath()+"/page/goToAddReportedCustomer";
		}
	});
}

function showAddCustom(){
	$('#customerDiv').show();
	$(".bg").fadeIn(100);
}

function addCustomer() {
	controllerWaiting(true);
	$(".bg").fadeIn(100);
	
	var customId=$("#customId").val();
	var emp=$("#emp").val();
	
	var customType=$("#customType").val();
	$.ajax({
		type:"post",
		dataType:"text",
		data:{
			"customId":customId,
			"empId":emp,
			"customType":customType
			},
		url:"../../authority/synJob/addAllotCustomer",
		success:function(msg) {
			controllerWaiting(false);
			$(".bg").fadeOut(100);
			if(msg==1){
				alert("添加成功!");
				
			} else {
				alert(msg);
			}
		},
		error:function(request) {
			alert("添加失败");
		}
	});
}

//二级联动
function changeClassB(hwnd) {
	var area=$("#area");
	$.ajax({
		type:"POST",
		dataType:"jsond",
		data:{"areaId":$(hwnd).attr("value")},
		url:getContextPath()+"/util/changeAreaForClassB",
		success:function(data) {
			area.empty();
			data=eval(data);
			area.append("<option value=''>请选择</option>");
			for(var i=0;i<data.length;i++) {
				var option=$("<option></option>");
				option.attr("value",data[i].areaID);
				option.attr("text",data[i].name);
				area.append(option);
			}
		}
	});
}